package com.xoa.controller.workflow;

import com.xoa.model.workflow.FlowOpinion;
import com.xoa.service.workflow.FlowOpinion.FlowOpinionService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

//常用意见设置
@Controller
@RequestMapping("/flowOpinion")
public class FlowOpinionController {
    @Autowired
    private FlowOpinionService flowOpinionService;

    @RequestMapping("/opinionSetting")
    public String index() {
        return "app/workflow/opinionSetting/opinionSetting";
    }

    //查询所有
    @ResponseBody
    @RequestMapping("/selectAllFlowOpinion")
    public ToJson<FlowOpinion> selectAllFlowOpinion() {
        return flowOpinionService.selectAllFlowOpinion();
    }

    //添加
    @ResponseBody
    @RequestMapping("/insertFlowOpinion")
    public ToJson<FlowOpinion> insertFlowOpinion(FlowOpinion flowOpinion, HttpServletRequest request) {
        return flowOpinionService.insertFlowOpinion(flowOpinion, request);
    }

    //根据id删除信息
    @ResponseBody
    @RequestMapping("/delFlowOpinion")
    public ToJson<FlowOpinion> delFlowOpinion(Integer opinionId) {
        return flowOpinionService.delFlowOpinion(opinionId);
    }

    //根据id删除信息(会签)
    @ResponseBody
    @RequestMapping("/delFlowOpinions")
    public ToJson<FlowOpinion> delFlowOpinions(Integer opinionId) {
        return flowOpinionService.delFlowOpinion2(opinionId);
    }

    //根据id查询单条信息
    @ResponseBody
    @RequestMapping("/selFlowOpinionById")
    public ToJson<FlowOpinion> selRelationFuncById(Integer opinionId) {
        return flowOpinionService.selFlowOpinionById(opinionId);
    }

    //根据id更新信息
    @ResponseBody
    @RequestMapping("/updateFlowOpinionById")
    public ToJson<FlowOpinion> updateFlowOpinionById(FlowOpinion flowOpinion, HttpServletRequest request) {
        return flowOpinionService.updateFlowOpinionById(flowOpinion, request);
    }


    //查询公共意见和个人意见
    @ResponseBody
    @RequestMapping("/selectFlowOpinion")
    public ToJson<FlowOpinion> selectFlowOpinion(HttpServletRequest request) {
        return flowOpinionService.selectFlowOpinion(request);
    }
}
